package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/smallest-subarrays-with-maximum-bitwise-or/
 * @create 2025/10/7 11:46
 * @since JDK17
 */

public class Solution07 {
    public int[] smallestSubarrays(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int x = nums[i];
            ans[i] = 1;
            for (int j = i - 1; j >= 0 && ((nums[j] | x) != nums[j]); j--) {
                nums[j] |= x;
                ans[j] = i - j + 1;
            }
        }

        return ans;
    }
}
